home *** CD-ROM | disk | FTP | other *** search
- HEAD
- by John Simonson
-
- HEAD.EXE will display the first 5 lines (by default) of specified
- text files. There are several switches that allow you to control
- the output.
-
- I wrote HEAD because of a terrible mistake I made. I had files on
- my Winchester drive that I had not backed up; one of these files was
- a 20 page document that was very important. Of course the hard disk
- crashed (of course at 2 mins. before quitting time on a Friday
- night...), and was so badly scrambled, that I had to clean out the
- disk with CHKDSK /F and then go through the resulting 2 meg of
- FILE????.CHK files (each file between 2 and 12K in size).
-
- After writing a routine to discover which of these files were pieces
- of binary files (i.e., largely non-printable ascii stuff) and
- deleting them, I still had a large number of files to go through and
- figure out which files could be used to recreate the important
- document. With HEAD I can list out the file names and the first few
- lines of each file, and by referring to the printed copy of the
- original document (yes, at least I had that) I could determine the
- correct order in which to append files.
-
- HEAD may be invoked as follows:
-
- HEAD filespec [-L [-T [-H [-N [-#]]]]]
-
- The option switches may appear in any order, and may precede or
- follow the file specification. The switches may be in upper or
- lower case, and MUST be preceded (without intervening spaces) by
- either a dash (-) or a slash (/). The file specifications may
- include any valid drive, optionally followed by any valid directory
- specifications, followed by any valid file name with extension. The
- file name and extension may contain wildcards. HEAD will not accept
- the slash (/) as subdirectory separator, which may cause you grief
- if you have specified the SWITCHAR as the dash (-) in your
- CONFIG.SYS. I may change this to allow only the (-) as an option
- flag and either (\) or (/) as the subdirectory separator in the next
- version of HEAD.
-
- The options you may select from are:
-
- -h Print a file name header for each file displayed. Each file
- displayed will be preceded by a line containing the file name, and a
- blank line.
-
- -l Print the line number with each line displayed.
-
- -n End each line displayed with an additional newline.
-
- -t Translate down (by decimal 128) all ascii characters with an ascii
- value greater than 127 (decimal). This effectively removes the soft
- carriage returns (ascii 141) produced by many word processors, and
- other such things that don't always display nicely to the screen.
- This does NOT mean that a soft carriage return will be replaced with
- a hard carriage return AND line feed; this is only a simple shifting
- down of the ascii value of existing characters.
-
- -# Don't really enter the number sign (#); rather, enter the number
- of lines you wish displayed from each file. The default value is
- set to 5.
-
- You may enter the options together (e.g., -hl20) or separately
- (e.g., -h -l -20). If entered separately, each switch must be
- preceeded by a space and a switch character (- or /). The command
- line is scanned for ALL option switches first, so options may
- preceed or follow or be interspersed with the file specifications.
-
- You must enter a file specification! The program will stop with a
- usage message if you fail to give it a file specification. You may
- give it more than one file specification. HEAD will expand all
- wildcard specifications, unless it is unable to find any files
- matching the specification. In that case, it will report (e.g. for
- HEAD *.bak)
-
- "HEAD: could not find any file *.bak"
-
- There is a similar caveat for the specification of the number of
- lines to be printed -- if you specify this option more than once,
- the last specification is used, the others are discarded.
-
-
- HEAD page 2
-
- You may also redirect the output, to a printer or to a file, e.g.,
-
- HEAD bozo.dat -l -h > prn
-
- to send output to the printer. You should also be able to pipe
- output to other programs (e.g., HEAD -10 *.DOC | SORT)
-
- The following examples may be of some help.
-
- HEAD -l -15 E:\CLIB\SOURCE\*.C -h
-
- would display the first fifteen (-15) lines with line numbers (-l)
- of all files ending with the extension ".C" on drive E in the
- subdirectory SOURCE of the subdirectory CLIB, preceding each file's
- output with a header line giving the file name.
-
- HEAD autoexec.ba?
-
- would display the first 5 lines (the default) of all files on the
- default drive and current directory with a name of "autoexec" and an
- extension that begain with ".ba" (e.g., .BAK and .BAT).
-
- HEAD *.doc -20 -t -8 or HEAD -20 *.doc -t8 or HEAD -20t8 *.doc
-
- would list the first 8 lines of all files with the extension ".DOC"
- on the current drive and directory. Note that the -20 is ignored,
- the -8 is accepted since it is the most recent setting specified.
- All characters greater than 127 decimal ascii value would be
- translated down by decimal 128.
-
- HEAD -h -l
-
- would produce an error message, informing you that you must specify
- a file or files.
-
- HEAD
-
- would produce a usage message, telling you what it wants.
-
- HEAD file1.txt file2.txt
-
- would display the first 5 lines (default) of file1.txt, with no
- header line, and no line numbers, followed immediately by the first
- 5 lines of file2.txt.
-
- HEAD -h nosuch.fil
-
- assuming "nosuch.fil" does not exist, HEAD will tell you it couldn't
- find file nosuch.fil.
-
- HEAD was written in C and originally compiled using Computer
- Innovation's C86 compiler (v 2.30), which seems to be a very nice
- compiler. The current version (2.1) was compiled using Microsoft C
- version 3.0 which produces smaller code.
-
- DISCLAIMER: I can't promise that the program will work as you expect
- it to; I've had few problems with it. This is really the first
- version, and I'm sure as it is used, people will find things that it
- could do better, or correctly, etc.. Feedback is welcome. It
- probably won't melt your machine not a pool of liquid silicon, but
- then again...
-
- NOTE: This program is copyrighted, but may be used, shared, and
- copied freely, as long as no charge is made for the program itself.
- I don't want any money for it (well, I could be persuaded....).
-
- John Simonson
- Department of Psychology
- University of Rochester
- Rochester, NY 14627
-
-
-
-
- This disk copy provided as a service of
-
- The Public (Software) Library
-
- the software library of
- The Houston Area League of PC Users
-
- Program disks are available for as little as $2 each and a
- 20-page monthly newsletter reviewing all the latest public
- domain and shareware software plus a listing of all the
- disks in our library is available for just $12 a year.
-
- For a copy of the latest monthly software library newsletter
- and program directory, send a self-addressed, stamped (with
- two stamps), legal-size envelope or send $1 to
-
- The Public (Software) Library
- P.O.Box 61565
- Dept. D
- Houston, TX 77208